package cn.mysdp.biz.facade;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import cn.mysdp.biz.dto.request.*;
import cn.mysdp.biz.dto.response.*;
import cn.mysdp.biz.domain.*;
import cn.mysdp.biz.facade.*;
import cn.mysdp.biz.facade.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: SdpSqlFacadeImpl
 * @Description:
 * @Author: SDP
 * @Date: 2021-10-30
 * @Version: 1.0
 * Table: sdp_sql
 * Comment:
 * 
 */
@Service
public class SdpSqlFacadeImpl extends SdpSqlFacadeCustomImpl implements SdpSqlFacade {

    static {
        beanClassNameMap.put("sdp_sql", "sdpSqlFacadeImpl");
        listMethodNameMap.put("sdp_sql", "listSdpSql");
        listMethodParameterClassNameMap.put("sdp_sql", "SdpSqlQueryRequest");
        updateMethodNameMap.put("sdp_sql", "updateSdpSql");
        updateMethodParameterClassNameMap.put("sdp_sql", "SdpSqlUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addSdpSql(SdpSqlAddRequest request) throws Exception {
        super.fixRequest("sdp_sql", "add", request);
        return super.addSdpSql(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateSdpSql(SdpSqlUpdateRequest request) throws Exception {
        SdpSql record = null;
        record = sdpSqlMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("sdp_sql", "update", request, record);
        return super.updateSdpSql(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteSdpSql(SdpSqlDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<SdpSql> list = null;
            SdpSqlExample example = new SdpSqlExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = sdpSqlMapper.selectByExample(example);
            fixRequest("sdp_sql", "delete", request, list);
        } else {
            fixRequest("sdp_sql", "delete", request);
        }
        return super.deleteSdpSql(request);
    }

    @Override
    public SdpSqlQueryResponse querySdpSql(SdpSqlQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        SdpSqlQueryResponse result = super.querySdpSql(request);
        checkResult("sdp_sql", "query", request, result);
        return result;
    }

    @Override
    public List<SdpSqlQueryResponse> listSdpSql(SdpSqlQueryRequest request) throws Exception {
        List<SdpSqlQueryResponse> list = super.listSdpSql(request);
        checkResult("sdp_sql", "list", request, list);
        return list;
    }

    @Override
    public Integer countSdpSql(SdpSqlQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_sql", "count", request);
        return super.countSdpSql(request);
    }

    @Override
    public BaseStatResponse statSdpSql(SdpSqlQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("sdp_sql", "stat", request);
        return super.statSdpSql(request);
    }

    @Override
    public Integer clone(BaseNameIdRequest request) throws Exception {
        super.fixRequest("sdp_sql", "clone", request);
        Integer result = super.clone(request);
        checkResult("sdp_sql", "clone", request, result);
        return result;
    }

}
